package cn.outsourcing.supermarket.service.impl;

import cn.outsourcing.supermarket.converter.HiolabsCategoryConverter;
import cn.outsourcing.supermarket.mapper.HiolabsCategoryMapper;
import cn.outsourcing.supermarket.po.HiolabsCategory;
import cn.outsourcing.supermarket.service.HiolabsCategoryService;
import cn.outsourcing.supermarket.vo.CategoryListVO;
import cn.outsourcing.supermarket.vo.CategoryVO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 服务实现类
 *
 * @author gzkemays
 * @since 2021-10-14
 */
@Service
public class HiolabsCategoryServiceImpl extends ServiceImpl<HiolabsCategoryMapper, HiolabsCategory>
    implements HiolabsCategoryService {
  @Resource HiolabsCategoryMapper categoryMapper;

  @Override
  public CategoryListVO getCategoryList() {
    return new CategoryListVO(
        categoryMapper.selectList(
            Wrappers.<HiolabsCategory>lambdaQuery()
                .eq(HiolabsCategory::getIsChannel, 1)
                .or()
                .eq(HiolabsCategory::getIsShow, 1)
                .or()
                .eq(HiolabsCategory::getIsCategory, 1)));
  }

  @Override
  public CategoryVO getCategoryDetail(Integer id) {
    return HiolabsCategoryConverter.INSTANCE.converterCategory(categoryMapper.selectById(id));
  }
}
